
/*
 * Copyright 2002-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2017原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory.wiring;

import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

/**
 * Holder for bean wiring metadata information about a particular class. Used in
 * conjunction with the {@link org.springframework.beans.factory.annotation.Configurable}
 * annotation and the AspectJ {@code AnnotationBeanConfigurerAspect}.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @since 2.0
 * @see BeanWiringInfoResolver
 * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory
 * @see org.springframework.beans.factory.annotation.Configurable
 */
/**
 *关于特定类的bean连接元数据信息的持有者。在中使用
 *与{@link.org.springframework.beans.factory.annotation.Configuration}结合使用
 *注释和AspectJ｛@code AnnotationBeanConfigurerAspect｝。
 *
 *@作者Rod Johnson
 *@作者Juergen Hoeller
 *@自2.0起
 *@参见BeanWiringInfoResolver
 *@参见org.springframework.beans.factory.config.AutowireCapableBeanFactory
 *@参见org.springframework.beans.factory.annotation.Configurationable
 */
public class BeanWiringInfo {

	/**
	 * Constant that indicates autowiring bean properties by name.
	 * @see #BeanWiringInfo(int, boolean)
	 * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
	 */
	/**
	 *通过名称指示自动连接bean财产的常量。
	 *@see#BeanWiringInfo（int，boolean）
	 *@see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
	 */
	public static final int AUTOWIRE_BY_NAME = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;

	/**
	 * Constant that indicates autowiring bean properties by type.
	 * @see #BeanWiringInfo(int, boolean)
	 * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
	 */
	/**
	 *指示按类型自动连接bean财产的常量。
	 *@see#BeanWiringInfo（int，boolean）
	 *@see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
	 */
	public static final int AUTOWIRE_BY_TYPE = AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE;


	@Nullable
	private String beanName;

	private boolean isDefaultBeanName = false;

	private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_NO;

	private boolean dependencyCheck = false;


	/**
	 * Create a default BeanWiringInfo that suggests plain initialization of
	 * factory and post-processor callbacks that the bean class may expect.
	 */
	/**
	 *创建一个默认的BeanWiringInfo，它建议
	 *bean类可能期望的工厂和后处理器回调。
	 */
	public BeanWiringInfo() {
	}

	/**
	 * Create a new BeanWiringInfo that points to the given bean name.
	 * @param beanName the name of the bean definition to take the property values from
	 * @throws IllegalArgumentException if the supplied beanName is {@code null},
	 * is empty, or consists wholly of whitespace
	 */
	/**
	 *创建一个指向给定bean名称的新BeanWiringInfo。
	 *@param beanName要从中获取属性值的bean定义的名称
	 *如果提供的beanName为｛@code null｝，则@throws IllegalArgumentException，
	 *为空，或完全由空格组成
	 */
	public BeanWiringInfo(String beanName) {
		this(beanName, false);
	}

	/**
	 * Create a new BeanWiringInfo that points to the given bean name.
	 * @param beanName the name of the bean definition to take the property values from
	 * @param isDefaultBeanName whether the given bean name is a suggested
	 * default bean name, not necessarily matching an actual bean definition
	 * @throws IllegalArgumentException if the supplied beanName is {@code null},
	 * is empty, or consists wholly of whitespace
	 */
	/**
	 *创建一个指向给定bean名称的新BeanWiringInfo。
	 *@param beanName要从中获取属性值的bean定义的名称
	 *@param isDefaultBeanName给定的bean名称是否为建议的
	 *默认bean名称，不一定与实际bean定义匹配
	 *如果提供的beanName为｛@code null｝，则@throws IllegalArgumentException，
	 *为空，或完全由空格组成
	 */
	public BeanWiringInfo(String beanName, boolean isDefaultBeanName) {
		Assert.hasText(beanName, "'beanName' must not be empty");
		this.beanName = beanName;
		this.isDefaultBeanName = isDefaultBeanName;
	}

	/**
	 * Create a new BeanWiringInfo that indicates autowiring.
	 * @param autowireMode one of the constants {@link #AUTOWIRE_BY_NAME} /
	 * {@link #AUTOWIRE_BY_TYPE}
	 * @param dependencyCheck whether to perform a dependency check for object
	 * references in the bean instance (after autowiring)
	 * @throws IllegalArgumentException if the supplied {@code autowireMode}
	 * is not one of the allowed values
	 * @see #AUTOWIRE_BY_NAME
	 * @see #AUTOWIRE_BY_TYPE
	 */
	/**
	 *创建一个新的BeanWiringInfo，指示自动布线。
	 *@param autowireMode常量之一｛@link#AUTOWIRE_BY_NAME｝/
	 *｛@link#AUTOWIRE_BY_TYPE｝
	 *@param dependencyCheck是否对对象执行依赖性检查
	 *bean实例中的引用（自动布线后）
	 *如果提供的｛@code autowireMode｝
	 *不是允许的值之一
	 *@参见#AUTOWIRE_BY_NAME
	 *@参见#AUTOWIRE_BY_TYPE
	 */
	public BeanWiringInfo(int autowireMode, boolean dependencyCheck) {
		if (autowireMode != AUTOWIRE_BY_NAME && autowireMode != AUTOWIRE_BY_TYPE) {
			throw new IllegalArgumentException("Only constants AUTOWIRE_BY_NAME and AUTOWIRE_BY_TYPE supported");
		}
		this.autowireMode = autowireMode;
		this.dependencyCheck = dependencyCheck;
	}


	/**
	 * Return whether this BeanWiringInfo indicates autowiring.
	 */
	/**
	 *返回此BeanWiringInfo是否指示自动布线。
	 */
	public boolean indicatesAutowiring() {
		return (this.beanName == null);
	}

	/**
	 * Return the specific bean name that this BeanWiringInfo points to, if any.
	 */
	/**
	 *返回此BeanWiringInfo指向的特定bean名称（如果有）。
	 */
	@Nullable
	public String getBeanName() {
		return this.beanName;
	}

	/**
	 * Return whether the specific bean name is a suggested default bean name,
	 * not necessarily matching an actual bean definition in the factory.
	 */
	/**
	 *返回特定bean名称是否为建议的默认bean名称，
	 *不一定与工厂中的实际bean定义匹配。
	 */
	public boolean isDefaultBeanName() {
		return this.isDefaultBeanName;
	}

	/**
	 * Return one of the constants {@link #AUTOWIRE_BY_NAME} /
	 * {@link #AUTOWIRE_BY_TYPE}, if autowiring is indicated.
	 */
	/**
	 *返回常量之一｛@link#AUTOWIRE_BY_NAME｝/
	 *｛@link#AUTOWIRE_BY_TYPE｝（如果指示自动布线）。
	 */
	public int getAutowireMode() {
		return this.autowireMode;
	}

	/**
	 * Return whether to perform a dependency check for object references
	 * in the bean instance (after autowiring).
	 */
	/**
	 *返回是否对对象引用执行相关性检查
	 *在bean实例中（在自动布线之后）。
	 */
	public boolean getDependencyCheck() {
		return this.dependencyCheck;
	}

}
